
package com.pekall.todo.util;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class AlarmUtil {
    public void setAlarm(Context context,int request,long time) {
        Intent i = new Intent(context, AlarmReceiver.class);
        PendingIntent pi = PendingIntent.getBroadcast(context, request, i, 0); // 通过getBroadcast第二个参数区分闹钟，将查询得到的note的ID值作为第二个参数。
        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.set(AlarmManager.RTC_WAKEUP, time, pi);// 设置闹铃
    }
    public void cancleAlarm(Context context,int request) {
         AlarmManager am = (AlarmManager)
         context.getSystemService(Context.ALARM_SERVICE);
         Intent i = new Intent(context, AlarmReceiver.class);
         PendingIntent pi = PendingIntent.getBroadcast(context, request, i, 0);
         am.cancel(pi);// 取消闹钟
    }

}
